package com.example.bean;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;


public class Result<T> implements Serializable{
	
	private int code;
	private String msg;
	private T data;
	
	public static final int SUCCESS = 200;
	
	
	public Result(){}
	public Result(int code){
		this.code = code;
	}
	public Result(int code, String msg){
		this.code = code;
		this.msg = msg;
	}
	public Result(int code, String msg, T data){
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	public boolean isSuccess(){
		if(code==SUCCESS){
			return true;
		}
		return false;
	}
	
	
	public boolean isFailed(){
		if(code==SUCCESS){
			return false;
		}
		return true;
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public T getData() {
		return data;
	}
	public void setData(T data) {
		this.data = data;
	}
	
	
	public String toString(){
		return JSONObject.toJSONString(this);
	}
	
	
}
